<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;

class BrandController extends CommonController{
	private $model;

	public function __construct(){
		parent::__construct();
		$this->model = new \Common\Model\Brand;
	}

	public function index(){
		$data = $this->model->get();
		View::with('data',$data);
		View::make();
	}

	public function add(){
		if(IS_POST){
			if($this->model->addData()){
				View::success('添加成功',U('index'));
			}
			View::error($this->model->getError());
		}
		View::make();
	}

	public function edit(){
		if(IS_POST){
			if($this->model->editData()){
				View::success('修改成功',U('index'));
			}
			View::error($this->model->getError());
		}
		$bid = Q('get.bid','0','intval');
		$oldData = $this->model->where("bid={$bid}")->find();
		View::with('oldData',$oldData);
		View::make();
	}

	public function del(){
		$bid = Q('get.bid','0','intval');
		$this->model->where("bid={$bid}")->delete();
		View::success('删除成功',U('index'));
	}
}


 ?>